/**
 */
package wcomm_v1.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import wcomm_v1.Activity;
import wcomm_v1.ActivityDefinition;
import wcomm_v1.EventPin;
import wcomm_v1.InPin;
import wcomm_v1.OutPin;
import wcomm_v1.Wcomm_v1Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Activity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link wcomm_v1.impl.ActivityImpl#getInstanceOf <em>Instance Of</em>}</li>
 *   <li>{@link wcomm_v1.impl.ActivityImpl#getOutPins <em>Out Pins</em>}</li>
 *   <li>{@link wcomm_v1.impl.ActivityImpl#getInPins <em>In Pins</em>}</li>
 *   <li>{@link wcomm_v1.impl.ActivityImpl#getEventPins <em>Event Pins</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ActivityImpl extends NamedElementImpl implements Activity
{
  /**
   * The cached value of the '{@link #getInstanceOf() <em>Instance Of</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInstanceOf()
   * @generated
   * @ordered
   */
  protected ActivityDefinition instanceOf;

  /**
   * The cached value of the '{@link #getOutPins() <em>Out Pins</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getOutPins()
   * @generated
   * @ordered
   */
  protected EList<OutPin> outPins;

  /**
   * The cached value of the '{@link #getInPins() <em>In Pins</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInPins()
   * @generated
   * @ordered
   */
  protected EList<InPin> inPins;

  /**
   * The cached value of the '{@link #getEventPins() <em>Event Pins</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEventPins()
   * @generated
   * @ordered
   */
  protected EList<EventPin> eventPins;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ActivityImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Wcomm_v1Package.Literals.ACTIVITY;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ActivityDefinition getInstanceOf()
  {
    if (instanceOf != null && instanceOf.eIsProxy())
    {
      InternalEObject oldInstanceOf = (InternalEObject)instanceOf;
      instanceOf = (ActivityDefinition)eResolveProxy(oldInstanceOf);
      if (instanceOf != oldInstanceOf)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, Wcomm_v1Package.ACTIVITY__INSTANCE_OF, oldInstanceOf, instanceOf));
      }
    }
    return instanceOf;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ActivityDefinition basicGetInstanceOf()
  {
    return instanceOf;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInstanceOf(ActivityDefinition newInstanceOf)
  {
    ActivityDefinition oldInstanceOf = instanceOf;
    instanceOf = newInstanceOf;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Wcomm_v1Package.ACTIVITY__INSTANCE_OF, oldInstanceOf, instanceOf));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<OutPin> getOutPins()
  {
    if (outPins == null)
    {
      outPins = new EObjectContainmentEList<OutPin>(OutPin.class, this, Wcomm_v1Package.ACTIVITY__OUT_PINS);
    }
    return outPins;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<InPin> getInPins()
  {
    if (inPins == null)
    {
      inPins = new EObjectContainmentEList<InPin>(InPin.class, this, Wcomm_v1Package.ACTIVITY__IN_PINS);
    }
    return inPins;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<EventPin> getEventPins()
  {
    if (eventPins == null)
    {
      eventPins = new EObjectContainmentEList<EventPin>(EventPin.class, this, Wcomm_v1Package.ACTIVITY__EVENT_PINS);
    }
    return eventPins;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.ACTIVITY__OUT_PINS:
        return ((InternalEList<?>)getOutPins()).basicRemove(otherEnd, msgs);
      case Wcomm_v1Package.ACTIVITY__IN_PINS:
        return ((InternalEList<?>)getInPins()).basicRemove(otherEnd, msgs);
      case Wcomm_v1Package.ACTIVITY__EVENT_PINS:
        return ((InternalEList<?>)getEventPins()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.ACTIVITY__INSTANCE_OF:
        if (resolve) return getInstanceOf();
        return basicGetInstanceOf();
      case Wcomm_v1Package.ACTIVITY__OUT_PINS:
        return getOutPins();
      case Wcomm_v1Package.ACTIVITY__IN_PINS:
        return getInPins();
      case Wcomm_v1Package.ACTIVITY__EVENT_PINS:
        return getEventPins();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.ACTIVITY__INSTANCE_OF:
        setInstanceOf((ActivityDefinition)newValue);
        return;
      case Wcomm_v1Package.ACTIVITY__OUT_PINS:
        getOutPins().clear();
        getOutPins().addAll((Collection<? extends OutPin>)newValue);
        return;
      case Wcomm_v1Package.ACTIVITY__IN_PINS:
        getInPins().clear();
        getInPins().addAll((Collection<? extends InPin>)newValue);
        return;
      case Wcomm_v1Package.ACTIVITY__EVENT_PINS:
        getEventPins().clear();
        getEventPins().addAll((Collection<? extends EventPin>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.ACTIVITY__INSTANCE_OF:
        setInstanceOf((ActivityDefinition)null);
        return;
      case Wcomm_v1Package.ACTIVITY__OUT_PINS:
        getOutPins().clear();
        return;
      case Wcomm_v1Package.ACTIVITY__IN_PINS:
        getInPins().clear();
        return;
      case Wcomm_v1Package.ACTIVITY__EVENT_PINS:
        getEventPins().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.ACTIVITY__INSTANCE_OF:
        return instanceOf != null;
      case Wcomm_v1Package.ACTIVITY__OUT_PINS:
        return outPins != null && !outPins.isEmpty();
      case Wcomm_v1Package.ACTIVITY__IN_PINS:
        return inPins != null && !inPins.isEmpty();
      case Wcomm_v1Package.ACTIVITY__EVENT_PINS:
        return eventPins != null && !eventPins.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //ActivityImpl
